﻿/*************************************************************************************

- CLR版本：        4.0.30319.42000
- 类 名 称：       CameraFactory
- 机器名称：       YTE
- 命名空间：       LD.Vision.Camera
- 文 件 名：       CameraFactory
- 创建时间：       2022/7/13 18:38:40
- 作    者：       YTE
- 说   明：
- 修改时间：
- 修 改 人：
  *************************************************************************************/

using LD.Host;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LD.Vision
{
    public class CameraFactory
    {
        private CameraType selectBrand;
        private static CameraFactory instance;
        private static object obj = new object();
        public static CameraFactory Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (obj)
                    {
                        if (instance == null)
                        {
                            instance = new CameraFactory();
                        }
                    }
                }
                return instance;
            }
        }
        /// <summary>
        /// 相机（使用中)
        /// </summary>
        public Dictionary<string, AbsCamera> CameraList { get; set; } = new Dictionary<string, AbsCamera>();

        public CameraType CameraBrand
        {
            set
            {
                switch (value)
                {
                    case CameraType.海康:
                        Hik();
                        break;
                    case CameraType.虚拟:
                        CameraList.Add("虚拟", new CameraVirtual("虚拟"));
                        break;
                }
            }
        }
        private void Hik()
        {
            //CameraList.Add("虚拟", new CameraVirtual("虚拟"));

            var hikList = new CameraHik();
            int index = 0;
            foreach (var item in hikList.GetCamera())
            {
                var hik = new CameraHik(item);
                CameraList.Add(item, hik);
                hik.Open(index);
                index++;
            }
            //hikList.Dispose();
        }
    }
}
